<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*,com.sp.model.*"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
<script type="text/javascript" src="js/laydate/laydate.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>添加新闻内容</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" enctype="multipart/form-data" onsubmit="return check(this)" action="TestServlet">  
      <div class="form-group">
        <div class="label">
          <label>标题：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="ntitle" data-validate="required:请输入标题" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>图片：</label>
        </div>
        <div class="field">
          <!-- <input type="text" disabled="disabled" id="url1" name="npic" class="input tips" style="width:25%; float:left;"  value=""  data-toggle="hover" data-place="right" data-image="" /> -->
          
          <input type="file" disabled="disabled" id="url1" name="npic" class="input tips" style="width:25%; float:left;"  value=""  data-toggle="hover" data-place="right" data-image="" />         
         
          
          <input type="button" class="button bg-blue margin-left" id="image1" value="+ 浏览上传"  style="float:left;">
          <div class="tipss">图片尺寸：500*500</div>
        </div>
      </div>     
      
      <if condition="$iscid eq 1">
        <div class="form-group">
          <div class="label">
            <label>类别：</label>
          </div>
          <div class="field">
            <select name="tid" class="input w50">
               <option value="">请选择类别</option>
              <%
     NTypeOper ntop=new NTypeOper();
     ArrayList<NTypeBean> al=ntop.GetTypeList();
     NTypeBean nt;
     int i;
        for(i=0;i<al.size();i++)  
                {  
                    nt=(NTypeBean)al.get(i);  
   %> 
           
                <option value="<%=nt.getTid()%>"><%=nt.getTname() %></option>
              <%} %>
       
            </select>
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>其他属性：</label>
          </div>
          <div class="field" style="padding-top:8px;"> 
            首页 <input id="ishome" value="ishome" type="checkbox"  name="checkbox1"/>
            推荐 <input id="isvouch" value="isvouch" type="checkbox" name="checkbox1"/>
            置顶 <input id="istop" value="istop" type="checkbox" name="checkbox1"/> 
         
          </div>
        </div>
      </if>
     
      <div class="form-group">
        <div class="label">
          <label>内容：</label>
        </div>
        <div class="field">
          <textarea name="content" class="input" style="height:250px; border:1px solid #ddd;"></textarea>
          <div class="tips"></div>
        </div>
      </div>
     
      

      <div class="form-group">
        <div class="label">
          <label>发布者：</label>
        </div>
        <div class="field">
          <!-- <input type="text" class="input w50" name="uname" value=""  /> -->
          <select name="uname" class="input w50">
          <%UserOper userOper = new UserOper();
            List<String> usernames = userOper.getUsersName();
            String option;
            for(String username:usernames){
            option="<option  value='"+username+"'>"+username+"</option>";
            out.println(option);
            }
            userOper.close();
          %>
          
          </select>
          <div class="tips"></div>
        </div>
      </div>
     
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>

</body>
</html>

<script>
$(document).ready(function(){

$("#image1").click(function (){
$("#url1").removeAttr("disabled");
$("#url1").click();
$("#url1").attr("disabled","disabled");
});


});
function check(form){
if(form.ntitle.value==""){
alert("请输入标题");
return false;
}
if(form.tid.value==""){
alert("请选择新闻类别");
return false;
}
if(form.content.value==""){
alert("请输入新闻内容");
return false;
}
$("#url1").removeAttr("disabled");
return true;
}
</script>
